<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/Static/Css/reset.css" />
<link rel="stylesheet" type="text/css" href="/Static/Css/zh-cn-system.css" />
<link rel="stylesheet" type="text/css" href="/Static/Css/table_form.css" />
<script src="/Public/js/jquery.min.js"></script>
<script src="/Public/js/jquery.form.js"></script>
<script src="/Public/js/main.js"></script>
<script type="text/javascript" src="/Public/artDialog/jquery.artDialog.js?skin=default"></script>
<script type="text/javascript" src="/Public/artDialog/plugins/iframeTools.js"></script>
</head>
<body>

<form method="post" action="" name="myform" id="myform">
<input name="id" type="hidden" value="<?php echo ($info['id']); ?>">
  <fieldset>
    <legend>基本信息</legend>
    <table class="table_form" width="100%" cellspacing="0">
      <tbody>
        <tr>
          <th>角色名称：</th>
          <td><input name="name" id="name" class="input-text" type="text" size="20" value="<?php echo ($info["name"]); ?>">
            <span class="onShow"></span></td>
        </tr>
        <tr class="last">
          <th>启用状态：</th>
          <td style="text-align:left">
          	<input type="radio" name="status" value="1" checked/>启用
            <input type="radio" name="status" value="0" />停用
		  </td>
        </tr>
        <tr>
          <th>排序：</th>
          <td><input name="sort" id="sort" class="input-text" type="text" size="10" value="<?php echo ($info["sort"]); ?>">
            注：数值越小越靠前</td>
        </tr>
        <tr class="last">
          <th>备注：</th>
          <td colspan="3"><textarea name="remark" id="remark" class="input-textarea" cols="75" rows="4"><?php echo ($info["remark"]); ?></textarea></td>
        </tr>
      </tbody>
    </table>
  </fieldset>
  <?php if(is_array($nodeList)): $i = 0; $__LIST__ = $nodeList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><fieldset>
    <legend><?php echo ($vo["title"]); ?></legend>
    <table class="table_form" width="100%" cellspacing="0">
      <tbody>
      	<tr><th width="90">全选：</th><td><input name="nodeIdArr[<?php echo ($vo["id"]); ?>]" class="appNodeId" type="checkbox" value="<?php echo ($vo["id"]); ?>" title="<?php echo ($vo["checked"]); ?>"></td></tr>
		<?php if(is_array($vo['model'])): $i = 0; $__LIST__ = $vo['model'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><tr>
          <th width="90"><input name="nodeIdArr[<?php echo ($vo["id"]); ?>][<?php echo ($v["id"]); ?>]" type="checkbox" value="<?php echo ($v["id"]); ?>" class="modelNodeId" title="<?php echo ($v["checked"]); ?>" style="float:left;" > <?php echo ($v["title"]); ?>：</th>
          <td>
            	<?php if(is_array($v['action'])): $i = 0; $__LIST__ = $v['action'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$cv): $mod = ($i % 2 );++$i;?><input name="nodeIdArr[<?php echo ($vo["id"]); ?>][<?php echo ($v["id"]); ?>][<?php echo ($cv['id']); ?>]" type="checkbox" value="<?php echo ($cv['id']); ?>" title="<?php echo ($cv["checked"]); ?>" class="actionNodeId" />
                    <span style="margin-left:5px; margin-right:10px; "><?php echo ($cv["title"]); ?></span><?php endforeach; endif; else: echo "" ;endif; ?>
          </td>
        </tr><?php endforeach; endif; else: echo "" ;endif; ?>
      </tbody>
    </table>
  </fieldset><?php endforeach; endif; else: echo "" ;endif; ?>
  <input type="submit" value="提交" class="dialog"  id="dosubmit">
</form>
</body>
</html>
<script type="text/javascript">
$(function(){
	var  status = "<?php echo ($info["status"]); ?>";
	if(status==0){
		$('input[name="status"]').attr("checked",'0');
	}

	$('#myform').ajaxForm({
		beforeSubmit:  checkForm,
		success:       complete,
		dataType: 'json'
	});
	function checkForm(){
		if($('#name').val().length < 2){
			$('#name').focus();
			checkInfo('name','分组名称不得少于2个字符');
			return false;
		}else{
			return true;
		}
	}

	var origin = $.artDialog.open.origin;

    function complete(data){
		msg(data.info,data.status);
		if(data.status)  setTimeout(function(){origin.location.reload();},1000);
		closeWin(1500);
    }

	//全选
	$(".appNodeId").change(function(){
		var appNodeId = $(this).attr('checked');
		if(appNodeId==true){
			 $(":checkbox").each(function() {
				this.checked=true;
			});
		}else{
			$(":checkbox").each(function() {
				this.checked=false;
			});
		}
	})

	//选择
	$(".modelNodeId").change(function(){
		if( $(this).attr('checked')==true ){
			$(this).parent().nextAll().find(":checkbox").each(function() {
				this.checked=true;
			});
		}else{
			$(this).parent().nextAll().find(":checkbox").each(function() {
				this.checked=false;
			});
		}
	})

	//设置默认权限
	$(".actionNodeId").each(function() {
    	var title = $(this).attr('title');
		if( title!='' ){
			this.checked=true;
		}
    });


})
</script>